<?php

class Sistema_Form_Procedimento extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        $this->setName('form_'.$controller);
        
        $el = new Zend_Form_Element_Hidden('PRC_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))->addFilter('Int');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_NOM');
        $el->setLabel('Nome')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Textarea('PRC_TXT');
        $el->setLabel('Texto')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_LCLAPL');
        $el->setLabel('Local de Aplicação')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_IND');
        $el->setLabel('Indicações')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        //$el = new Zend_Form_Element_Text('PRC_CNTIND');
        //$el->setLabel('Contraindicações')
        //->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        //$this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_BNF');
        $el->setLabel('Benefícios')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_SES');
        $el->setLabel('Sessões')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_PRVRTD');
        $el->setLabel('Previsão para Resultado')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        //$el = new Zend_Form_Element_Text('PRC_DRCEFT');
        //$el->setLabel('Duração de Efeito')
        //->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        //$this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PRC_ITDDOR');
        $el->setLabel('Intensidade da Dor')
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        
        $img2 = 'public/upload/'.$controller.'/'.$front->getRequest()->getParam('id').'_lst.*';
        foreach (glob($img2) as $src) {
            $el = new Zend_Form_Element('img2',array( 'helper'=>'formNote', 'value'=>'<img src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        $el = new Zend_Form_Element_File('PRC_FILE2');
        $el->setLabel('Listagem - Tamanho: ___x___');
	//->addValidator('Extension', false, array('jpg', 'png', 'gif'));
        $this->addElement($el);
        
        /*
        $img = 'public/upload/'.$controller.'/'.$front->getRequest()->getParam('id').'.*';
        foreach (glob($img) as $src) {
            $el = new Zend_Form_Element('img',array( 'helper'=>'formNote', 'value'=>'<img src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        $el = new Zend_Form_Element_File('PRC_FILE');
        $el->setLabel('Detalhe - Tamanho: ___x___');
	//->addValidator('Extension', false, array('jpg', 'png', 'gif'));
        $this->addElement($el);
        */
        
        $el = new Zend_Form_Element_Text('PRC_ORD');
        $el->setLabel('Ordem')
        ->setRequired(true)
        ->addFilter('Int')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Checkbox('PRC_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('Salvar',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setLabel('Salvar');
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
    }


}

